<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div-son :fruit="fruit">
            <template slot-scope="slotProps">
                <strong v-if="slotProps.info.id == 2">{{ slotProps.info.name }}</strong>
                <span v-else>{{ slotProps.info.name }}</span>
            </template>
        </div-son>
    </div>

    <script>
        Vue.component('div-son',{
            props: ['fruit'],
            template: `
            <ul>
                <li :key="item.id" v-for="item in fruit">
                    <slot :info="item">{{ item.name }}</slot>
                </li>
            </ul>
            `
        });
        var vm = new Vue({
            el: '#app',
            data: {
                fruit: [{
                    id: 1,
                    name: 'apple',
                },{
                    id: 2,
                    name: 'orange'
                },{
                    id: 3,
                    name: 'banana'
                }]
            },
            methods: {
                enlarge: function(){
                    this.font += 4;
                },
                Delete: function(){
                    Hub.$off('former-event');
                }
            }
        })
    </script>
</body>
</html>